import Vue from '@vue/compat'
import { createStore } from 'vuex'
// import Vuex from 'vuex'
import getters from './getters'
import app from './modules/app'
// import settings from './modules/settings'
import NodeParams from './modules/NodeParams'
import flow from './modules/flow/'
import EventBus from '../libs/EventBus'
import { Emitter } from "@/utils/Emitter";
// import designer from '@/store/modules/designer/index'
import {AppParams} from '@/utils/appParams'
// 用户设计界面
// import animation from '../views/UserPage/Designer/store/animation'
// import compose from '../views/UserPage/Designer/store/compose'
// import contextmenu from '../views/UserPage/Designer/store/contextmenu'
// import copy from '../views/UserPage/Designer/store/copy'
// import event from '../views/UserPage/Designer/store/event'
// import layer from '../views/UserPage/Designer/store/layer'
// import snapshot from '../views/UserPage/Designer/store/snapshot'
// import lock from '../views/UserPage/Designer/store/lock'
// import align from '../views/UserPage/Designer/store/align'
// import Config from './modules/designer/Config'
// import compose from './modules/designer/compose'
// import animation from './modules/designer/animation'
// import contextmenu from './modules/designer/contextmenu'
// import copy from './modules/designer/copy'
// import event from './modules/designer/event'
// import layer from './modules/designer/layer'
// import snapshot from './modules/designer/snapshot'
// import lock from './modules/designer/lock'
// import align from './modules/designer/align'

// Vue.use(Vuex)
const store = createStore({
  modules: {
    app,
    // settings,
    NodeParams,
    flow,
    // event,
  },
  getters
})

/**
 * 节点完成事件，
 * 包括成功/失败
 * NodeStatus ：
 *        0 节点失败(默认值)
 *        1 节点成功
 * 更新节点日志
 */
EventBus.$on(AppParams.JAVA_SCRIPT_EVENT.NODE_COMPLETE, (v) => {
  store.commit('flow/chat/UPDATE_NODE_STATUS', v)
  store.commit('app/UPDATE_NODE_LOGGER', v)
})

Emitter.on(AppParams.JAVA_SCRIPT_EVENT.NODE_LOGGER, (v) => {
  store.commit('app/UPDATE_NODE_LOGGER', v)
})
EventBus.$on(AppParams.JAVA_SCRIPT_EVENT.NODE_ERROR, (v) => {
  store.commit('app/UPDATE_NODE_LOGGER', {})
})


Emitter.on(AppParams.JAVA_SCRIPT_EVENT.NODE_CLICK, (v) => {
  store.commit('flow/chat/SET_CURRENT_NODE', v)
})
export default store
